<?php

namespace app\selladmin\model;

use think\Model;
use think\Db;

/*
 * 体验卡
 */

class Expercard extends Model {

    //体验卡对应的店铺信息
    public function Store() {
        return $this->hasOne('Store', 'id', 'store_id')->field('id,store_name');
    }

    //体验卡列表
    public function ExpercardList($store_id, $pagenum) {
        if ($store_id) {
            $experiencestorewhere['store_id'] = $store_id;
        }
        $experiencestorewhere = isset($experiencestorewhere) ? $experiencestorewhere : [];
        $ExperienceStoreList = Expercard::with('store')
                ->where($experiencestorewhere)
                ->order("add_time desc")
                ->paginate($pagenum)
                ->appends($experiencestorewhere);
        return $ExperienceStoreList;
    }

     //体验卡项目列表
    public function ExperienceItemList($expercard_id, $pagenum) {
        if ($expercard_id) {
            $experiencestorewhere['expercard_id'] = $expercard_id;
        }
        $experiencestorewhere = isset($experiencestorewhere) ? $experiencestorewhere : [];
        $ExperienceStoreList = Db::name('expercard_item')
                ->where($experiencestorewhere)
                ->paginate($pagenum)
                ->appends($experiencestorewhere);
        return $ExperienceStoreList;
    }
    //体验卡客户列表
    public function ExperienceCustomList($expercard_id, $pagenum) {
        if ($expercard_id) {
            $experiencestorewhere['expercard_id'] = $expercard_id;
        }
        $experiencestorewhere = isset($experiencestorewhere) ? $experiencestorewhere : [];
        $ExperienceStoreList = ExpercardCustom::with('Custom')
                ->where($experiencestorewhere)
                ->paginate($pagenum)
                ->appends($experiencestorewhere);
        return $ExperienceStoreList;
    }
}

